using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace ASP_TF2LogParser.UserControls
{
    public partial class PlayerListControl : System.Web.UI.UserControl
    {
        LogParser.DA.PlayerModel _model;

        protected void Page_Load( object sender, EventArgs e )
        {
            //_model = new LogParser.DA.PlayerModel();
            
            
            //LogParser.DA.DataObjects.PlayerStatsDS.PlayerShortStatsDataTable pssdt = _model.GetPlayerShortStats();

            //if ( !Page.IsPostBack )
            //    pssdt.DefaultView.Sort = "Kills DESC, KillDeathRatio DESC, Deaths Desc";

            //this.playerListgv.DataSourceID = String.Empty;
            //this.playerListgv.DataSource = pssdt;
            //this.playerListgv.DataBind();

            

        }

        //#region Sorting

        //protected void playerListgv_Sorting( object sender, GridViewSortEventArgs e )
        //{
        //    DataTable dataTable = playerListgv.DataSource as DataTable;

        //    if ( dataTable != null )
        //    {
        //        //DataView dataView = new DataView( dataTable );
        //        //dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql( GridViewSortDirection );


        //        dataTable.DefaultView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql( GridViewSortDirection );
        //        playerListgv.DataSource = dataTable;
        //        playerListgv.DataBind();
        //    }



        //}

        //public SortDirection GridViewSortDirection
        //{
        //    get
        //    {
        //        if ( ViewState[ "sortDirection" ] == null )
        //            ViewState[ "sortDirection" ] = SortDirection.Ascending;

        //        SortDirection returnDirection = ( SortDirection ) ViewState[ "sortDirection" ];

        //        if ( ( SortDirection ) ViewState[ "sortDirection" ] == SortDirection.Ascending )
        //            ViewState[ "sortDirection" ] = SortDirection.Descending;
        //        else
        //            ViewState[ "sortDirection" ] = SortDirection.Ascending;



        //        return returnDirection;
        //    }
        //    set { ViewState[ "sortDirection" ] = value; }
        //}

        //private string ConvertSortDirectionToSql( SortDirection sortDirection )
        //{
        //    string newSortDirection = String.Empty;

        //    switch ( sortDirection )
        //    {
        //        case SortDirection.Ascending:
        //            newSortDirection = "ASC";
        //            break;

        //        case SortDirection.Descending:
        //            newSortDirection = "DESC";
        //            break;
        //    }

        //    return newSortDirection;
        //}

        //#endregion


        public string GenerateUrl( string playerName, string playerId )
        {

            string returnUrl = "";

            returnUrl = "<a href='Player.aspx?playerId=" + playerId + "'>" + playerName + "</a>";
            
            return returnUrl;


        }

    }
}